home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 December / PCWDEC06.iso / Software / Trial / Paint Shop Pro XI / Data1.cab / _3D810C4631234F38929E3299949996E2 < prev    next >
Encoding:
Text File  |  2006-08-04  |  3.9 KB  |  87 lines

  1. from PSPApp import *
  2. import PSPUtils
  3.  
  4. def ScriptProperties():
  5.     return {
  6.         'Author': u'Corel Corporation',
  7.         'Copyright': u'Copyright (c) 2002-2006 Corel Corporation. All rights reserved.',
  8.         'Description': "Merge the selected objects into the first object selected rewind the contours.",
  9.         'Host': u'Paint Shop Pro 9',
  10.         'Host Version': u'9.00'
  11.     }
  12.  
  13.  
  14. def Do(Environment):
  15.     # get the set of selected objects
  16.     Result = App.Do( Environment, 'ReturnVectorObjectProperties', { 'GeneralSettings': {'Version': ((9,0,0),1)}})
  17.     ObjList = Result['ListOfObjects']
  18.  
  19.     # use list comprehension to get a list of all the regular objects and all the text
  20.     # objects.  We don't care about the text objects, but if any exist we can't do the
  21.     # merge
  22.     if ObjList is not None:
  23.         MergeableObjects = [ Obj for Obj in ObjList if Obj['ObjectData'] is not None ]
  24.         TextExObjects = [ Obj for Obj in ObjList if Obj['TextExData'] is not None ]
  25.         TextObjects = [ Obj for Obj in ObjList if Obj['TextData'] is not None ]
  26.         RectangleObjects = [ Obj for Obj in ObjList if Obj['RectangleData'] is not None ]
  27.         EllipseObjects = [ Obj for Obj in ObjList if Obj['EllipseData'] is not None ]
  28.         SymmetricShapeObjects = [ Obj for Obj in ObjList if Obj['SymmetricShapeData'] is not None ]
  29.     else:
  30.         App.Do(Environment,  'MsgBox', {
  31.                     'Buttons': App.Constants.MsgButtons.OK, 
  32.                     'Icon': App.Constants.MsgIcons.Info, 
  33.                     'Text': PSPUtils.TwoOrMoreMsg,
  34.                                         'GeneralSettings': {
  35.                                             'Version': ((9,0,0),1)
  36.                                             }
  37.                     })
  38.         return
  39.     x = 0
  40.     if len(TextExObjects) > 0:
  41.         x = 1
  42.     elif len(TextObjects) > 0:
  43.         x = 1
  44.     elif len(RectangleObjects) > 0:
  45.         x = 1
  46.     elif len(EllipseObjects) > 0:
  47.         x = 1
  48.     elif len(SymmetricShapeObjects) > 0:
  49.         x = 1
  50.     if x:
  51.         App.Do( Environment, 'ConvertToPath', {'GeneralSettings': {'Version': ((9,0,0),1)}})
  52.         Result = App.Do( Environment, 'ReturnVectorObjectProperties', {'GeneralSettings': {'Version': ((9,0,0),1)}} )
  53.         ObjList = Result['ListOfObjects']
  54.         if ObjList is not None:
  55.             MergeableObjects = [ Obj for Obj in ObjList if Obj['ObjectData'] is not None ]
  56.     if len(MergeableObjects) < 2:
  57.         App.Do(Environment,  'MsgBox', {
  58.                     'Buttons': App.Constants.MsgButtons.OK, 
  59.                     'Icon': App.Constants.MsgIcons.Info, 
  60.                     'Text': PSPUtils.TwoOrMoreMsg,
  61.                                         'GeneralSettings': {
  62.                                             'Version': ((9,0,0),1)
  63.                                             }
  64.                     })
  65.         return
  66.  
  67.     # delete all the selected objects
  68.     App.Do( Environment, 'ClearSelection', {'GeneralSettings': {'Version': ((9,0,0),1)}} )
  69.  
  70.     # Create the base object by taking the first thing in the mergeable list
  71.     App.Do( Environment, 'AddGroupsAndObjects', {'ListOfObjects': [MergeableObjects[0]],
  72.                                                      'GeneralSettings': {'Version': ((9,0,0),1) }} )
  73.  
  74.     # now add all the other objects - we could rewind the contours after every object, but
  75.     # there is a performance penalty to doing so, so we only put the windpath parameter
  76.     # on the last object in the list.
  77.     for Obj in MergeableObjects[1:-1]: # take everything after the first object    
  78.         App.Do( Environment, 'NodeEditAddPath', { 'Path': Obj['ObjectData']['Path'],
  79.                                                           'WindPath': App.Constants.Boolean.false,
  80.                                                           'GeneralSettings': {'Version': ((9,0,0),1) }})
  81.         
  82.     # on the last object set the winding flag so that nested objects become cutouts
  83.     Obj = MergeableObjects[-1]
  84.     App.Do( Environment, 'NodeEditAddPath', { 'Path': Obj['ObjectData']['Path'],
  85.                                                   'WindPath': App.Constants.Boolean.false,
  86.                                                   'GeneralSettings': {'Version': ((9,0,0),1) }})
  87.